From 7734700c78d087315eb6829de3bd87e019dc26d5 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Thu, 7 Jun 2007 22:16:19 +0000 Subject: [PATCH] * (bug 8760) Allow wiki links in "protectexpiry" message * Introduce wfMsgWithLinks() and a content-language counterpart, wfMsgForContentWithLinks(); these escape HTML and render wiki links in text, so should be suitable for labels and so on * Make Linker::formatLinksInComment() public --- RELEASE-NOTES | 1 + includes/GlobalFunctions.php | 27 +++++++++++++++++++++++++++ includes/Linker.php | 11 ++++++----- includes/ProtectionForm.php | 21 +++++---------------- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 913830db8e..d946df00ef 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -66,6 +66,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN files * (bug 7997) Allow users to be blocked from using Special:Emailuser * (bug 8989) Blacklist 'mhtml' and 'mht' files from upload +* (bug 8760) Allow wiki links in "protectexpiry" message == Bugfixes since 1.10 == diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 6ab81e509e..b39a8abeae 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -326,6 +326,20 @@ function wfMsg( $key ) { return wfMsgReal( $key, $args, true ); } +/** + * Get a message in the user interface language and replace wiki + * links with clickable ones, escaping other HTML + * + * @param string $key Message key + * @return string + */ +function wfMsgWithLinks( $key ) { + global $wgUser; + $args = func_get_args(); + return $wgUser->getSkin()->formatLinksInComment( htmlspecialchars( + call_user_func_array( 'wfMsg', $args ) ) ); +} + /** * Same as above except doesn't transform the message */ @@ -368,6 +382,19 @@ function wfMsgForContent( $key ) { return wfMsgReal( $key, $args, true, $forcontent ); } +/** + * Get a message in the content language and replace wiki + * links with clickable ones, escaping other HTML + * + * @param string $key Message key + * @return string + */ +function wfMsgForContentWithLinks( $key ) { + global $wgUser; + return $wgUser->getSkin()->formatLinksInComment( htmlspecialchars( + call_user_func_array( 'wfMsgForContent', func_get_args() ) ) ); +} + /** * Same as above except doesn't transform the message */ diff --git a/includes/Linker.php b/includes/Linker.php index 548505c555..989a2895ea 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -926,12 +926,13 @@ class Linker { } /** - * Format regular and media links - all other wiki formatting is ignored - * Called by Linker::formatComment. - * @param $comment The comment text. - * @return Comment text with links using HTML. + * Formats wiki links and media links in text; all other wiki formatting + * is ignored + * + * @param string $comment Text to format links in + * @return string */ - private function formatLinksInComment( $comment ) { + public function formatLinksInComment( $comment ) { global $wgContLang; $medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|'; diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 02aa42147a..d261358e5b 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -318,22 +318,11 @@ class ProtectionForm { } function buildExpiryInput() { - $id = 'mwProtect-expiry'; - - $ci = ""; - $ci .= wfElement( 'label', array ( - 'id' => "$id-label", - 'for' => $id ), - wfMsg( 'protectexpiry' ) ); - $ci .= " "; - $ci .= wfElement( 'input', array( - 'size' => 60, - 'name' => $id, - 'id' => $id, - 'value' => $this->mExpiry ) + $this->disabledAttrib ); - $ci .= ""; - - return $ci; + $attribs = array( 'id' => 'expires' ) + $this->disabledAttrib; + return '' + . '' + . '' . Xml::input( 'mwProtect-expiry', 60, $this->mExpiry, $attribs ) . '' + . ''; } function buildWatchInput() { -- 2.20.1